package com.flying.function.direct;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.function.context.FunctionCatalog;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Flux;

import java.util.function.Function;

@SpringBootApplication
public class FunctionDemo {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(FunctionDemo.class);
        FunctionCatalog catalog = context.getBean(FunctionCatalog.class);
        Function<Flux<String>, Flux<String>> function = catalog.lookup("uppercase");
        function.apply(Flux.just("hello", "dfd")).subscribe(System.out::println);
    }

    @Bean
    public Function<String, String> uppercase() {
        return String::toUpperCase;
    }
}
